package com.tanhua.server.controller;

import com.tanhua.model.dto.RecommendUserDto;
import com.tanhua.model.vo.NearUserVo;
import com.tanhua.model.vo.PageResultVo;
import com.tanhua.model.vo.TodayBestVo;
import com.tanhua.server.service.TanhuaService;
import jdk.management.resource.internal.ResourceNatives;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.w3c.dom.stylesheets.LinkStyle;

import javax.ws.rs.PATCH;
import java.util.List;
import java.util.Map;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/12/1 12:40
 */
@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private TanhuaService tanhuaService;

    /**
     * 今日佳人
     * @return
     */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){

        TodayBestVo vo = tanhuaService.findTodayBest();
        return ResponseEntity.ok(vo);
    }

    /**
     * 交友--朋友推荐查询
     * @param dto
     * @return
     */
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserDto dto){

        PageResultVo vo = tanhuaService.recommendationByPage(dto);
        return ResponseEntity.ok(vo);
    }

    /**
     * 佳人信息
     * 点击推荐，显示佳人详细信息
     * @param id
     * @return
     */
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable("id") Long id){

        TodayBestVo vo = tanhuaService.personalInfo(id);
        return ResponseEntity.ok(vo);
    }

    /**
     * 查看陌生人问题
     * @param userId
     * @return
     */
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){

        String question = tanhuaService.strangerQuestions(userId);
        return ResponseEntity.ok(question);
    }

    /**
     * 回复陌生人问题
     * @param map
     * @return
     */
    @PostMapping("/strangerQuestions")
    public ResponseEntity replyQuestions(@RequestBody Map map){

        String id = map.get("userId").toString();
        Long userId = Long.valueOf(id);
        String reply = map.get("reply").toString();
        tanhuaService.replyQuestions(userId, reply);
        return ResponseEntity.ok(null);

    }

    /**
     * 探花-推荐用户列表
     * @return
     */
    @GetMapping("/cards")
    public ResponseEntity queryCardsList(){

        List<TodayBestVo> list =  tanhuaService.queryCardsList();
        return ResponseEntity.ok(list);
    }


    /**
     * 右滑-喜欢
     * @param likeUserId
     * @return
     */
    @GetMapping("{id}/love")
    public ResponseEntity<Void> likeUser(@PathVariable("id") Long likeUserId) {

        tanhuaService.likeUser(likeUserId);
        return ResponseEntity.ok(null);
    }

    /**
     * 不喜欢
     * @param likeUserId
     * @return
     */
    @GetMapping("{id}/unlove")
    public ResponseEntity<Void> notLikeUser(@PathVariable("id") Long likeUserId) {

        tanhuaService.notLikeUser(likeUserId);
        return ResponseEntity.ok(null);
    }


    /**
     * 搜索附件
     * @param gender
     * @param distant
     * @return
     */
    @GetMapping("/search")
    public ResponseEntity searchNear(String gender,
                                     @RequestParam(defaultValue = "2000") String distant){

        List<NearUserVo> vo =  tanhuaService.searchNear(gender, distant);
        return ResponseEntity.ok(vo);
    }

}
